package com.qiang.util;

import java.util.concurrent.*;

/**
 */
public class ExcutorUtil {

    static ExecutorService fixedThreadPool = null;
    static final Integer nThreads = 50;

    static {
        if (fixedThreadPool == null) {
            fixedThreadPool = new ThreadPoolExecutor(nThreads, nThreads,
                    0L, TimeUnit.MILLISECONDS,
                    new LinkedBlockingQueue<>(200)/*,
                    new ThreadPoolExecutor.CallerRunsPolicy()*/);
        }
    }

    public static void execute(Thread thread) {
        fixedThreadPool.execute(thread);
    }

    public static Future<?> submit(Callable<?> c) {
        return (Future<?>) fixedThreadPool.submit(c);
    }


    public static void execute(Runnable runnable) {
        fixedThreadPool.execute(runnable);
    }
}

